'''
拿到依赖的值
依赖的值，就是依赖用例的remark
通过循环遍历用例中所有remark字段，将它们的值全部存入t_list
使用依赖的值去循环判断t_list中的值，添加一个变量counter作为计数器，用于定位符合条件的列表下标
通过计数器找到依赖用例的值，拼接为请求并发送，获取到依赖用例返回的结果
'''

import sys
sys.path.append('.')
from data.yewu_data import test_data
from business.niubi_common import run_main
import config as c


def get_depend(data):
    t_list=[]
    for i in range(len(test_data)):
        t = test_data[i]['remark']
        t_list.append(t)
    counter = 0
    for check_data in t_list:
        if data == check_data:
            metho = test_data[counter]['method']
            url = c.base_url + test_data[counter]['path']
            body = test_data[counter]['data']
            cookie = c.read_cookie()
            body['accesstoken'] = c.token
            r = run_main(metho,url,body,cookie)
        else:
            counter += 1
            continue
    return r.json()

if __name__ == "__main__":
    data = test_data[3]['depend_case']
    print(data)
    print(get_depend(data))